﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using DevExpress.Web.ASPxEditors;

using Entities;
using BLL;


namespace Stationery.UC
{
    public partial class UC_TotalFaqs : System.Web.UI.UserControl
    {
        BLL_Faqs bll_Faqs = new BLL_Faqs();
        protected void Page_Load(object sender, EventArgs e)
        {
            ShowFaqsTop();
        }
        private void ShowFaqsTop()
        {
            DataTable dt = new DataTable();
            dt = bll_Faqs.Get_Faqs_Top();
            if (dt.Rows.Count <= 0)
            {
                return;
            }
            else
            {
                DataList.DataSource = dt;
                DataList.DataBind();
            }
        }

        protected void DataList_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item != null)
            {
                DataRowView dtrv = (DataRowView)e.Item.DataItem;

                HyperLink hltitle = (HyperLink)e.Item.FindControl("HyperLinkTitle1");
                hltitle.Text = dtrv["Title"].ToString();
                hltitle.NavigateUrl = "~/WebFaqs.aspx?viewtype=detail&faqid=" + dtrv["Faq_id"].ToString();

                Label label = (Label)e.Item.FindControl("LabelNewsDate");
                DateTime dt = (DateTime)dtrv["Create_date"];
                label.Text = "(" + dt.ToString("dd/MM/yyyy") + ")";

                HtmlGenericControl hldesc = (HtmlGenericControl)e.Item.FindControl("DivQuestion");
                hldesc.InnerHtml = dtrv["Question"].ToString();

                HyperLink hlView = (HyperLink)e.Item.FindControl("HyperLinkView");
                hlView.Text = Utils.link_detail;
                hlView.NavigateUrl = "~/WebFaqs.aspx?viewtype=detail&faqid=" + dtrv["Faq_id"].ToString();
            }
        }
    }
}